package net.sky.oa.dao.system.impl;

import java.util.ArrayList;
import java.util.List;

import net.sky.oa.dao.SkyBaseDaoImpl;
import net.sky.oa.dao.system.SysEmployeeLeaveDao;
import net.sky.oa.model.SysEmployeeLeave;

import org.springframework.stereotype.Repository;

import com.htsoft.core.web.paging.PagingBean;

@SuppressWarnings("unchecked")
@Repository
public class SysEmployeeLeaveDaoImpl extends SkyBaseDaoImpl<SysEmployeeLeave> implements SysEmployeeLeaveDao {
    
	public SysEmployeeLeaveDaoImpl(){
		super.setPersistType(SysEmployeeLeave.class);
	}
	
	public List<SysEmployeeLeave> findAllLeave() {
		return null;
	}
	
	public List<SysEmployeeLeave> getLeave(Long userId, Integer type, PagingBean pb) {
		String xtype;
		if(type == 3) xtype = "s.type = 3"; 
		else xtype = "(s.type = 1 or s.type = 2)";
		String hql = "from SysEmployeeLeave s where s.user.id="+userId + " and "+xtype+" order by s.time desc";
		List list = new ArrayList();
		return findByHql(hql, list.toArray(),pb);
	}
	
}
